<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
        + path + "/";
        %>
<!doctype html>
<html>
<head>
    <base href="<%=basePath%>" />
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="layui/css/layui.css" media="all"> <!-- 适应所有设备 -->
    <style type="text/css">
    </style>
</head>
<% String nowDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); %>
<body>
<form class="layui-form">
    <div class="layui-form-item" align="center">
        <input type="hidden" id="#gameId" name="gameId">
        <input type="hidden" id="#roomNum" name="roomNum">
        <br/>
        <input class="layui-input"type="number" min="0" placeholder="血池的修改值" name="hp">
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="editHP">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<input type="hidden" class="zid">

<script src="js/jquery.min.js"></script>
<script src="layui/layui.js"></script>
<script>
    layui.use(['layer','form'],function(){
        var layer = layui.layer,
            form  = layui.form;
        var upLockClicktag = 0;
        form.on('submit(editHP)',function(data){
            console.log(localStorage.getItem("roomNum"));
            console.log(localStorage.getItem("gameId"));
            // console.log(parent.roomNum);
            // console.log(data.field.hp);
            if(upLockClicktag == 0){
                upLockClicktag = 1;
                if (null == data.field.hp || "" == data.field.hp || "" == $.trim(data.field.hp)) {
                    layer.msg("请输入修改值");
                    return false;
                }
                $.ajax({
                    type:'POST',
                    url:'room/updateHP',
                    async:true,
                    data:{
                        gameId:localStorage.getItem("gameId"),
                        roomNum:localStorage.getItem("roomNum"),
                        hp:data.field.hp
                    },
                    success:function(resp){
                        if(resp == "success"){
                            layer.msg("设置成功",{icon:1});
                            setTimeout(function(){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                                parent.layui.table.reload('AllTable',{
                                    page:{
                                        cuur:1
                                    },
                                    where:{
                                        gameId: localStorage.getItem("gameId")
                                    }
                                });
                            },1000);
                        }else{
                            layer.msg("操作失败 ",{icon:2});
                            setTimeout(function(){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                                parent.layui.table.reload('AllTable',{
                                    page:{
                                        cuur:1
                                    },
                                    where:{
                                        gameId: localStorage.getItem("gameId")
                                    }
                                });
                            },1000);
                        }
                    }
                });
                return false;
                setTimeout(function () { upLockClicktag = 0 }, 3000);
            }else{
                layer.msg("请勿频繁操作！！！",{icon:2});
            }
        });
    });
</script>
</body>
</html>